// 定义和医院设置相关的函数
import { Key } from 'react'
import { request } from '@utils/http'
// 引入
import {
  IhospitalSetRes,
  Iadd,
  IhospitalSetItem,
} from '@api/hospital/hospitalSet/model/hospitalSetTypes'
// 获取医院设置
export function reqGetHospitalSets(
  page: number,
  limit: number,
  hosname?: string,
  hoscode?: string
) {
  // 写泛型,是明确这次请求响应的数据类型
  return request.get<any, IhospitalSetRes>(
    `/admin/hosp/hospitalSet/${page}/${limit}`,
    {
      //get请求上传参数,在配置对象中写params.最终还是会拼接成查询字符串
      params: {
        hosname,
        hoscode,
      },
    }
  )
}

// 添加医院设置
export function reqAddHospitalSet(data: Iadd) {
  return request.post<any, null>(`/admin/hosp/hospitalSet/save`, data)
}

//获取一条医院设置
export function reqGetHospitalSet(id: number) {
  return request.get<any, IhospitalSetItem>(`/admin/hosp/hospitalSet/get/${id}`)
}

// 修改医院设置
export function reqUpdateHospitalSet(data: Iadd) {
  return request.put<any, null>(`/admin/hosp/hospitalSet/update`, data)
}
export function reqDelHospitalSet(id: number) {
  return request.delete<any, null>(`/admin/hosp/hospitalSet/remove/${id}`)
}
export function reqBatchDelHospitalSet(ids: Key[]) {
  return request.delete<any, null>(`/admin/hosp/hospitalSet/batchRemove`, {
    data: ids,
  })
}
